<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        .big{
            display: flex;
            margin: 80px;
        }
        li{
            list-style: none;
            width: 150px;
            height: 35px;
            padding-top: 3px;
            padding-left: 25px;
        }
        .right{
            border-left: 1px solid #f3f3f3;
            padding-left: 35px;
        }
        .k{
            width: 300px;
            height: 30px;
        }
        textarea{
            width: 300px;
            height: 200px;
            resize: none;
        }
        p{
            margin-top: 20px;
        }
        button{
            width: 100px;
            height: 30px;
            background-color: #4b92f7;
            color: #fff;
            border: 0;
        }
        h4{
            margin-top: 60px;
            margin-left: 60px;
        }
        img{
            width: 200px;
            height: 200px;
            background-color: #4b92f7;
            margin-left: 80px;
            border-radius: 50%;
        }
    </style>
</head>
<body>
    <div class="big">
        <ul>
            <li style="background-color: #eaf7fe; border-right: 4px solid #4b92f7; color:#4b92f7 ; ">基本设置</li>
            <li>安全设置</li>
            <li>账号绑定</li>
            <li>新消息通知</li>
        </ul>
        <div class="right">
            <h3>基本设置</h3>
            <p>邮箱</p>
            <p><input type="text" class="k"></p>
            <p>昵称</p>
            <p><input type="text" class="k"></p>
            <p>性别</p>
            <p><input type="radio" name="sex">男 <input type="radio" name="sex">女</p>
            <p>个人简介</p>
            <p><textarea></textarea></p>
            <p><button>提交</button></p>
        </div>
        <div>
            <h4>头像</h4>
            <img src="" alt=""><br>
            <p style="display: flex;">
                <button onclick="gh()" style="margin-left: 130px; margin-top: 10px; border: 1px solid #999; color: black; background-color: #fff;">更换头像</button>
                <input type="file" class="wj" style="display: none;  margin-top: 13px; margin-left: 15px;">
            </p>
        </div>
    </div>
</body>
</html>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
    var wj=document.querySelector('.wj')
    var img=document.querySelector('img')
    function gh(){
        wj.style.display='block'
    }
    wj.addEventListener('change',function(e){
        let fd=new FormData()
        fd.append('img',e.target.files[0])
        var xhr=new XMLHttpRequest
        xhr.open ('post','https://hmajax.itheima.net/api/uploadimg')
        xhr.upload.onprogress=function(ev){
            var per =(ev.loaded/ev.total)*100+'%'
        }
        xhr.send(fd)
        xhr.onreadystatechange=function(){
            if(xhr.readyState==4&&xhr.status==200){
                let res=JSON.parse(xhr.response)
                img.src=res.data.url
            }
        }
    })
</script>